const request = require("request");
const execSync = require("child_process").execSync;

try {
	let gitPush = require("../../package.json").gitPush;
	if (!gitPush) {
		process.exit(0);
	}
	const gitUrl = execSync("git remote get-url --push origin", { encoding: "utf-8" });
	if (gitUrl) {
		request.get(`${ gitPush }?remote=${gitUrl}`, (err, res) => {
			if (err) {
				console.log(err);
			} else {
				console.log("[gitPushHook]推送结果: " + res.body);
			}
		});
	}
} catch (error) {
	console.log(error);
	process.exit(0);
}